// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using System;
using System.Linq;
using Elastic.Clients.Elasticsearch.Serialization;

namespace Elastic.Clients.Elasticsearch.Fluent;

public readonly partial struct FluentDictionaryOfFieldScriptField<TDocument>
{
	private readonly System.Collections.Generic.Dictionary<Elastic.Clients.Elasticsearch.Field, Elastic.Clients.Elasticsearch.ScriptField> _items = new();

	private System.Collections.Generic.IDictionary<Elastic.Clients.Elasticsearch.Field, Elastic.Clients.Elasticsearch.ScriptField> Value => _items;

	public FluentDictionaryOfFieldScriptField()
	{
	}

	public Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldScriptField<TDocument> Add(Elastic.Clients.Elasticsearch.Field key, Elastic.Clients.Elasticsearch.ScriptField value)
	{
		_items.Add(key, value);
		return this;
	}

	public Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldScriptField<TDocument> Add(System.Linq.Expressions.Expression<System.Func<TDocument, object?>> key, Elastic.Clients.Elasticsearch.ScriptField value)
	{
		_items.Add(key, value);
		return this;
	}

	public Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldScriptField<TDocument> Add(Elastic.Clients.Elasticsearch.Field key, System.Action<Elastic.Clients.Elasticsearch.ScriptFieldDescriptor> action)
	{
		_items.Add(key, Elastic.Clients.Elasticsearch.ScriptFieldDescriptor.Build(action));
		return this;
	}

	public Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldScriptField<TDocument> Add(System.Linq.Expressions.Expression<System.Func<TDocument, object?>> key, System.Action<Elastic.Clients.Elasticsearch.ScriptFieldDescriptor> action)
	{
		_items.Add(key, Elastic.Clients.Elasticsearch.ScriptFieldDescriptor.Build(action));
		return this;
	}

	[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
	internal static System.Collections.Generic.IDictionary<Elastic.Clients.Elasticsearch.Field, Elastic.Clients.Elasticsearch.ScriptField> Build(System.Action<Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldScriptField<TDocument>>? action)
	{
		if (action is null)
		{
			return new System.Collections.Generic.Dictionary<Elastic.Clients.Elasticsearch.Field, Elastic.Clients.Elasticsearch.ScriptField>();
		}

		var builder = new Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldScriptField<TDocument>();
		action.Invoke(builder);
		return builder.Value;
	}
}

public readonly partial struct FluentDictionaryOfFieldScriptField
{
	private readonly System.Collections.Generic.Dictionary<Elastic.Clients.Elasticsearch.Field, Elastic.Clients.Elasticsearch.ScriptField> _items = new();

	private System.Collections.Generic.IDictionary<Elastic.Clients.Elasticsearch.Field, Elastic.Clients.Elasticsearch.ScriptField> Value => _items;

	public FluentDictionaryOfFieldScriptField()
	{
	}

	public Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldScriptField Add(Elastic.Clients.Elasticsearch.Field key, Elastic.Clients.Elasticsearch.ScriptField value)
	{
		_items.Add(key, value);
		return this;
	}

	public Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldScriptField Add<T>(System.Linq.Expressions.Expression<System.Func<T, object?>> key, Elastic.Clients.Elasticsearch.ScriptField value)
	{
		_items.Add(key, value);
		return this;
	}

	public Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldScriptField Add(Elastic.Clients.Elasticsearch.Field key, System.Action<Elastic.Clients.Elasticsearch.ScriptFieldDescriptor> action)
	{
		_items.Add(key, Elastic.Clients.Elasticsearch.ScriptFieldDescriptor.Build(action));
		return this;
	}

	public Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldScriptField Add<T>(System.Linq.Expressions.Expression<System.Func<T, object?>> key, System.Action<Elastic.Clients.Elasticsearch.ScriptFieldDescriptor> action)
	{
		_items.Add(key, Elastic.Clients.Elasticsearch.ScriptFieldDescriptor.Build(action));
		return this;
	}

	[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
	internal static System.Collections.Generic.IDictionary<Elastic.Clients.Elasticsearch.Field, Elastic.Clients.Elasticsearch.ScriptField> Build(System.Action<Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldScriptField>? action)
	{
		if (action is null)
		{
			return new System.Collections.Generic.Dictionary<Elastic.Clients.Elasticsearch.Field, Elastic.Clients.Elasticsearch.ScriptField>();
		}

		var builder = new Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldScriptField();
		action.Invoke(builder);
		return builder.Value;
	}
}